home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb / sprite / i386_procDebugRegs.c.old < prev    next >
Encoding:
Text File  |  1990-11-14  |  3.4 KB  |  114 lines

  1. /* 
  2.  * procDebugRegs.c --
  3.  *
  4.  *    Convert registers between the format expected by the ptrace system
  5.  *    call and that of the Sprite Proc_Debug call.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  */
  16.  
  17. #ifndef lint
  18. static char rcsid[] = "$Header: /sprite/lib/forms/RCS/proto.c,v 1.2 89/01/07 04:12:18 rab Exp $ SPRITE (Berkeley)";
  19. #endif /* not lint */
  20.  
  21. #include "sprite.h"
  22. #include "status.h"
  23. #include <sys/types.h>
  24. #include "sys/ptrace.h"
  25. #include <errno.h>
  26. #include <proc.h>
  27. #include <signal.h>
  28. #include <sys/wait.h>
  29. #include "machine/reg.h"
  30. #include "procDebugRegs.h"
  31.  
  32.  
  33. /*
  34.  *----------------------------------------------------------------------
  35.  *
  36.  * procDebugToPtraceRegs --
  37.  *
  38.  *    Convert registers from a proc debug format to a ptrace format.
  39.  *
  40.  * Results:
  41.  *    None.
  42.  *
  43.  * Side effects:
  44.  *    None.
  45.  *
  46.  *----------------------------------------------------------------------
  47.  */
  48.  
  49. void
  50. procDebugToPtraceRegs(regStatePtr, ptraceRegsPtr)
  51.     Mach_RegState    *regStatePtr; /* Register state as returned by 
  52.                        * the PROC_GET_DBG_STATE argument
  53.                        * to Proc_Debug. */
  54.     char    *ptraceRegsPtr;          /* Memory to put ptrace format of
  55.                        * registers. */
  56.  
  57. {
  58.     register struct pt_regset *regs = (struct pt_regset *) ptraceRegsPtr;
  59.  
  60.         regs->pr_eax = regStatePtr->userRegs.trapEAX;
  61.         regs->pr_ebx = regStatePtr->userRegs.trapEBX;
  62.         regs->pr_ecx = regStatePtr->userRegs.trapECX;
  63.         regs->pr_edx = regStatePtr->userRegs.trapEDX;
  64.         regs->pr_esi = regStatePtr->userRegs.trapESI;
  65.         regs->pr_edi = regStatePtr->userRegs.trapEDI;
  66.         regs->pr_ebp = (unsigned int) regStatePtr->userRegs.trapEBP;
  67.         regs->pr_esp = (unsigned int) regStatePtr->userRegs.trapESP;
  68.         regs->pr_eip = (unsigned int) regStatePtr->userRegs.trapEIP;
  69.         regs->pr_flags = regStatePtr->userRegs.trapFlags;
  70.     regs->pr_fpu = regStatePtr->userFPURegs;
  71.     return;
  72. }
  73.  
  74.  
  75. /*
  76.  *----------------------------------------------------------------------
  77.  *
  78.  * ptraceToProcDebugRegs --
  79.  *
  80.  *    Convert registers from a ptrace format to a proc debug format.
  81.  *
  82.  * Results:
  83.  *    None.
  84.  *
  85.  * Side effects:
  86.  *    None.
  87.  *
  88.  *----------------------------------------------------------------------
  89.  */
  90.  
  91. void
  92. ptraceToProcDebugRegs(ptraceRegsPtr, regStatePtr)
  93.     char    *ptraceRegsPtr;          /* Memory image of ptrace format of
  94.                        * registers. */
  95.     Mach_RegState    *regStatePtr; /* Register state as used by Proc_Debug */
  96.  
  97. {
  98.     register struct pt_regset *regs = (struct pt_regset *) ptraceRegsPtr;
  99.  
  100.     regStatePtr->userRegs.trapEAX = regs->pr_eax;
  101.     regStatePtr->userRegs.trapEBX = regs->pr_ebx;
  102.     regStatePtr->userRegs.trapECX = regs->pr_ecx;
  103.     regStatePtr->userRegs.trapEDX = regs->pr_edx;
  104.     regStatePtr->userRegs.trapESI = regs->pr_esi;
  105.     regStatePtr->userRegs.trapEDI = regs->pr_edi;
  106.     regStatePtr->userRegs.trapEBP = (Address) regs->pr_ebp;
  107.     regStatePtr->userRegs.trapESP = (Address) regs->pr_esp;
  108.     regStatePtr->userRegs.trapEIP = (Address) regs->pr_eip;
  109.     regStatePtr->userRegs.trapFlags = regs->pr_flags;
  110.     regStatePtr->userFPURegs = regs->pr_fpu;
  111.     return;
  112. }
  113.  
  114.